#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
const int maxn = 105;
char pw[maxn];
bool used[27];
string qian,hou,dai;

int main(){
	cin>>qian>>hou>>dai;
	if(hou.size()<26){
		cout<<"Failed"<<endl;
		return 0;
	}
	for(int i=0;i<hou.size();i++){
		used[hou[i]-'A']=true;
	}
	for(int i=0;i<qian.size();i++){
		if(!used[qian[i]-'A']){
			cout<<"Failed"<<endl;
			return 0;
		}else{
			if(pw[qian[i]-'A']==0){
				pw[qian[i]-'A']=hou[i];
			}else if(pw[qian[i]-'A']!=hou[i]){
				cout<<"Failed"<<endl;
				return 0;
			}
		}
	}
	for(int i=0;i<dai.size();i++){
		cout<<pw[dai[i]-'A'];
	} 
	cout<<endl;
	return 0;
}
